package config

import com.alipay.api.DefaultAlipayClient
import factory.ActionFactory
import javax.security.auth.login.Configuration
import org.springframework.beans.factory.InitializingBean
import org.springframework.beans.factory.annotation.Value

@Configuration
class AliExampleProperties extends AliPayProperties with InitializingBean{
  /**
   * 应用ID
   */
  @Value("${xxxx}") private val appid:String = null

  /**
   * 商户的私钥
   */
  @Value("${xxxx}") private val privateKey:String = null

  /**
   * 支付回调地址
   */
  @Value("${xxxx}") private val notifyURL:String = null

  /**
   * 支付宝网关
   */
  @Value("${xxxx}") private val gateway:String = null

  /**
   * 支付宝的公钥
   */
  @Value("${xxxx}") private val aliPublicKey:String = null


  override def getAppid: String = appid

  override def getPrivateKey: String = privateKey

  override def getNotifyURL: String = notifyURL

  override def getGateway: String = gateway

  override def getAliPublicKey: String = aliPublicKey

  override def afterPropertiesSet(): Unit = ActionFactory.setAliPayProperties("aliExample", this)

  override def getAlipayClient = new DefaultAlipayClient(getGateway, getAppid, getPrivateKey, format, charset, getAliPublicKey, signType)
}
